import React, { Component } from 'react'
import Header from './ui/Header';
import Swiper from './ui/Swiper';
import Search from './ui/Search'
import Hotcate from './ui/Hotcate'
import Goodfood from './ui/Goodfood'

import connect from './connect'

@connect
class Cookbook extends Component {

  componentDidMount() {
    // 两个都成功才是真的成功
    Promise.all([
      this.props.addSwiperAction(),
      this.props.addHotCateAction(),
      this.props.addGoodfoodAction()
    ])
  }

  render() {
    return (
      <div>
        <Header></Header>
        <Swiper data={this.props.swiper}></Swiper>
        <Search></Search>
        <Hotcate data={this.props.hotcate}></Hotcate>
        <Goodfood data={this.props.goodfood}></Goodfood>
      </div>
    );
  }
}

export default Cookbook;
